<template>
  <transition name="slide">
      <div class="model" v-if="showModel">
        <!-- <div class="mask">123</div> -->
        <div class="model-dialog">
            <div class="model-header">
                <span>提示</span>
                <a href="javascript:;" class="icon-close" @click="$emit(cancel)" ></a>
            </div>
            <div class="model-body">
                <div class="body" v-for="(item, index) in showDataList" :key="index">
                    <span v-text="item.name + ':'"></span>
                    <input :type="item.type" v-model="item.default" /><!--:text="item.default"-->
                </div>
                <!-- <div class="body">这是条消息</div> -->
            </div>
            <div class="model-footer">
                <button class="btn" @click="callBack">确认</button>
                <button class="btn" @click="$parent.showModel = false">取消</button>
            </div>
        </div>
    </div>
  </transition>
</template>
<script>
export default {
    name: "model",
    props: {
        showModel: {
            type: Boolean,
            default() {
                return false
            }
        },
        showDataList: {
            type: Array,
            default() {
                return [
                    {"name":"备注", "default": "备注信息", "type": "text", "verify": null}
                ]
            }
        },
        dataType: {
          type: String,
          default() {
            return "remark"
          }
        },
        id: {
          type: Number,
          default() {
            return -1
          }
        }
    },
    data () {
        return {
            
        }
    },
    methods: {
        callBack() {
              // this.$parent.showModel = false
            // console.log(this.dataType)
            // console.log(JSON.stringify(this.showDataList)+"||")
            this.$parent.modelCallBack(this.showDataList, this.dataType, this.id)
        }
    }
}
</script>
<style>
.mask {
    /*这里用固定定位，后面设置动画时才不受影响 */
  position: fixed;
  top: 0;
  height: 100%;
  width: 100%;
  background-color: rgba(167, 165, 165, 0.486);
  opacity: 0.5;
  z-index: 9;
}
.model-dialog {
  position: absolute;
  /*让弹框居中显示*/
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: #fff;
  border-radius: 12px;
  width: 100%;
  height: 300px;
  border: 1px solid #f5f5f5;
  overflow: hidden;
  /*这里注意层级要比mask大，覆盖它*/
  z-index: 10;
}
.model-header {
  position: relative;
  height: 50px;
  padding-left: 10px;
  padding-top: 10px;
  font-size: 20px;
  line-height: 50px;
  background-color: #f5f5f5;
  border-bottom: 1px solid rgb(177, 176, 176);
}
.model-body {
  height: 30px;
  line-height: 30px;
  font-size: 15px;
  text-align: center;
  background-color: #fff;
}
.model-footer {
  background-color: #f5f5f5;
  height: 100px;
  text-align: center;
  line-height: 100px;
  margin-top: 110px;
}
.btn {
  width: 100px;
  height: 40px;
  border-radius: 8px;
  background-color: rgb(180, 103, 103);
  color: #fff;
  font-size: 18px;
  border: none;
}
.icon-close {
/*如果不加绝对布局，图表显示不出来*/
  position: absolute;
  background-color: pink;
  right: 15px;
  top: 16px;
  width: 30px;
  height: 30px;
  z-index: 10;
  background: url("http://pic.616pic.com/ys_img/00/14/17/ywY6h6XA4b.jpg") no-repeat;
  background-size: contain;
}
.model {
  z-index: 10;
  transition: all 0.5s;
}
.slide-enter-active {
  top: 0;
}

.slide-leave-active {
  top: -100%;
}
.slide-enter {
  top: -100%;
}

</style>
